<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <title>挂号</title>

    <link rel="shortcut icon" href="assets/img/logo2x.png"/>
    <!-- Bootstrap core CSS -->
    <link href="assets/css/bootstrap.css" rel="stylesheet"/>
    <!--external css-->
    <link rel="stylesheet" type="text/css" href="assets/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="assets/css/zabuto_calendar.css">
    <link rel="stylesheet" type="text/css" href="assets/js/gritter/css/jquery.gritter.css"/>
    <link rel="stylesheet" type="text/css" href="assets/lineicons/style.css">

    <!-- Custom styles for this template -->
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/style-responsive.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body onload="initDept()">

<section id="container">
    <div th:replace="tools :: header"></div>

    <div th:replace="tools :: sidebar "></div>


    <!-- **********************************************************************************************************************************************************
    MAIN CONTENT
    *********************************************************************************************************************************************************** -->
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper site-min-height">
            <div class="row col-lg-12">
                <div class="form-panel">
                    <button class="btn " onclick="window.history.back()"><i class="fa fa-angle-left"></i> 返 回
                    </button>
                    <button class="btn " onclick="javascript:location.reload();"><i class="fa fa-refresh"></i> 刷新
                    </button>
                    <button class="btn btn-success " onclick="newApt()"> <i class="fa fa-check-square"></i>&nbsp; 提 交 </button>
                </div>
            </div>

            <div class="row col-lg-12">
                <div class="form-panel">
                    <h3 class="centered"><i class="fa fa-angle-right"></i> 预约挂号 <i class="fa fa-angle-left"></i></h3>
                    <hr>
                    <form id="newAppointment" method="post">
                        <div class="form-group form-inline">
                            <h3>挂号类型</h3>
                            <select class="form-control" id="rgtype" name="rgtype">
                                <option value="personal">本人挂号</option>
                                <option value="otpeople">为他人挂号</option>
                            </select>
                        </div>
                        <div class="otpinfo form-inline" hidden>
                            <h3>患者信息</h3>
                            <label class="h4">姓名</label>
                            <input type="text" name="ptname" class="form-control">
                            <label class="h4">性别</label>
                            <select class="form-control" name="ptgender">
                                <option>男</option>
                                <option>女</option>
                            </select>
                            <br>
                            <label class="h4">年龄</label>
                            <input type="number" name="ptage" class="form-control">
                            <label class="h4">生日</label>
                            <input type="date" id="ptbirthday" name="ptbirthday" class="form-control">
                        </div>
                        <div class="form-group form-inline">
                            <h3>请选择科室类别</h3>
                            <select id="deptid" class="form-control" required>
                                <option value="">--请选择科室类别--</option>
                            </select>
                        </div>
                        <div class="form-group form-inline">
                            <h3>选择科室</h3>
                            <select id="roomid" class="form-control" name="deptid" required>
                                <option value="">--请选择科室--</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <h3>请选择医生</h3>
                            <div class="form-group">
                                <div class="row mt" id="docpanel">

                                </div>
                                <!--<div class="inline-block form-inline">-->
                                    <!--<button class="btn" onclick="switchPage('pre')"> 上一页</button>-->
                                    <!--<button class="btn" onclick="switchPage('nxt')"> 下一页</button>-->
                                    <!--<button class="btn" onclick="switchPage('goto')">前往</button>-->
                                    <!--<input class="form-control" placeholder="页码" type="number">-->
                                    <!--第 <span class="cpspan">1</span> 页-->
                                    <!--共 <span>2</span>页-->
                                    <!--<input hidden="" id="cpage" value="1">-->
                                <!--</div>-->
                            </div>
                        </div>
                        <div class="form-group form-inline">
                            <h3>选择时间</h3>
                            <input type="date" class="form-control" name="aptdate" id="aptdate" required>
                            <select class="form-control" name="time" required>
                                <option value="1">8:00-10:00</option>
                                <option value="2">10:00-11:30</option>
                                <option value="3">13:00-15:00</option>
                                <option value="4">15:00-17:00</option>
                                <option value="5">18:30-19:30</option>
                            </select>
                        </div>

                    </form>
                </div>
            </div>

        </section>
        <! --/wrapper -->

    </section>

    <!--main content end-->

    <!--**********************************************************************************************
    Footer
    **********************************************************************************************-->

    <!--footer start-->
    <footer class="site-footer">
        <div class="text-center">
            Copyright © 2018 David Bai
            <a href="#main-content" class="go-top">
                <i class="fa fa-angle-up"></i>
            </a>
        </div>
    </footer>
    <!--footer end-->
</section>


<!-- js placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/jquery-1.8.3.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script class="include" type="text/javascript" src="assets/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="assets/js/jquery.scrollTo.min.js"></script>
<script src="assets/js/jquery.nicescroll.js" type="text/javascript"></script>
<script src="assets/js/jquery.sparkline.js"></script>

<!--common script for all pages-->
<script src="assets/js/common-scripts.js"></script>

<script>

    $(function () {
        initDate(aptdate);
        initDate(ptbirthday);
    });

    $("#rgtype").change(function () {
        if($("#rgtype").val() == "otpeople"){
            $(".otpinfo").attr("hidden",false);
        }else {
            $(".otpinfo").attr("hidden",true);
        }
    });

    function newApt() {
        $.post("/cappoint",$("#newAppointment").serialize(),function (data) {
            alert(data.message);
            if(data.state == 100){
                location.href="/records";
            }
        });
    }


</script>
</body>
</html>
